/*******************************************************************************
 * Copyright (c) 2014 Francesco Gabbrielli (http://www.francescogabbrielli.it).
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Francesco Gabbrielli - initial API and implementation
 ******************************************************************************/
package it.francescogabbrielli.android.solidalapp;

import javax.jdo.annotations.NotPersistent;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;

@Entity
public class Request extends Message {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	protected Long id;

	/** Credits offered */
	private int credits;

	/** Expiry timestamp */
	private long expiry;
		
	/** Duration in minutes */
	private int duration;
	
	/** More info (i.e. on location/address) */
	private String details;
		
	/** If the request has been accepted by a registered user */
	private boolean accepted;
	
	/** Radius of the request */
	private int radius; 
	
	/** If the request has expired */
	@NotPersistent
	@Transient
	private boolean expired;
	
	@Override
	public Long getId() {
		return id;
	}	
	
	public int getCredits() {
		return credits;
	}
	
	public void setCredits(int credits) {
		this.credits = credits;
	}
	
	public long getExpiry() {
		return expiry;
	}
	
	public void setExpiry(long expiry) {
		this.expiry = expiry;
	}
	
	public boolean isExpired() {
		return expired;
	}
	
	public void setExpired(boolean expired) {
		this.expired = expired;
	}
	
	public int getDuration() {
		return duration;
	}
	
	public void setDuration(int duration) {
		this.duration = duration;
	}
	
	public String getDetails() {
		return details;
	}
	
	public void setDetails(String details) {
		this.details = details;
	}
	
	public int getRadius() {
		return radius;
	}
	
	public void setRadius(int radius) {
		this.radius = radius;
	}
	
	public boolean isAccepted() {
		return accepted;
	}
	
	public void setAccepted(boolean accepted) {
		this.accepted = accepted;
	}
	
	@Override
	public String toString() {
		return "REQUEST "
				+ (getId()!=null ? getId() : "<new>")
				+ ": DEVICE "+ getDeviceId();
	}

}
